wiki

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

make.wht (2063B)


      1 # Make (GNU Make)
      2 
      3 This article is a stub.
      4 
      5 ```makefile
      6 CC=gcc
      7 CXX=g++
      8 RM=rm -f
      9 CPPFLAGS=-g -Wall -Wextra -Werror -I./lib/godot-cpp/include
     10 LDFLAGS=-g
     11 LDLIBS=
     12 
     13 # SOURCES=tool.cc support.cc
     14 # OBJS=$(subst .cc,.o,$(SOURCES))
     15 
     16 SOURCES := $(wildcard src/*.cpp)
     17 OBJS=$(patsubst src/%.cpp,obj/%.o,$(SOURCES))
     18 
     19 all: $(OBJS)
     20 
     21 $(OBJS): $(SOURCES)
     22     $(CXX) $(LDFLAGS) $< -o $@ $(LDLIBS)
     23 
     24 clean:
     25 	$(RM) $(OBJS)
     26 
     27 # Outputs target name
     28 echo $@
     29 
     30 # Outputs all prerequisites newer than the target
     31 echo $?
     32 
     33 # Outputs all prerequisites
     34 echo $^
     35 
     36 # Outputs the first prerequisite
     37 echo $<
     38 
     39 # Simple assignment :=
     40 # A simple assignment expression is evaluated only once, at the very first occurrence. For example, if CC :=${GCC} ${FLAGS} during the first encounter is evaluated to gcc -W then each time ${CC} occurs it will be replaced with gcc -W.
     41 
     42 # Recursive assignment =
     43 # A Recursive assignment expression is evaluated everytime the variable is encountered in the code. For example, a statement like CC = ${GCC} {FLAGS} will be evaluated only when an action like ${CC} file.c is executed. However, if the variable GCC is reassigned i.e GCC=c++ then the ${CC} will be converted to c++ -W after the reassignment.
     44 
     45 # Conditional assignment ?=
     46 # Conditional assignment assigns a value to a variable only if it does not have a value
     47 
     48 # Appending +=
     49 # Assume that CC = gcc then the appending operator is used like CC += -w
     50 # then CC now has the value gcc -W
     51 
     52 # WINLIBS :=  -L"/c/Windows/System32" \
     53 # 			-l:ntdll.dll \
     54 # 			-l:KERNEL32.DLL \
     55 # 			-l:KERNELBASE.dll \
     56 # 			-l:msvcrt.dll  \
     57 # 			-l:advapi32.dll  \
     58 # 			-l:sechost.dll  \
     59 # 			-l:RPCRT4.dll  \
     60 # 			-l:CRYPTBASE.DLL  \
     61 # 			-l:bcryptPrimitives.dll
     62 
     63 # -MM make makedeps
     64 # -MT specify which file to generate depends for
     65 # -MF output file
     66 $(DEPFILES): .deps/%.d: src/%.cpp src/%.h
     67 	g++ -MM -MT $(patsubst src/%.cpp,bin/%.o,$<) -MF $@ $(GODOT_CPP_INCLUDES) -Isrc $<
     68 
     69 NODEPS := clean purge
     70 
     71 ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
     72 	-include $(DEPFILES)
     73 endif
     74 ```
     75 
     76 [filename](../hub/linux.md ':include')
     77