opengl_learn

step-by-step introduction to OpenGL
git clone https://0xdd.org/code/opengl_learn.git
Log | Files | Refs | README | LICENSE

Makefile (1460B)


      1 OGL_BIN = ogl/ogl.a
      2 
      3 00_SRC = 00-triangle.c 
      4 00_OBJ = $(00_SRC:.c=.o) $(OGL_BIN)
      5 00_BIN = 00-triangle
      6 
      7 01_SRC = 01-perspective.c
      8 01_OBJ = $(01_SRC:.c=.o) $(OGL_BIN)
      9 01_BIN = 01-perspective
     10 
     11 02_SRC = 02-cube.c
     12 02_OBJ = $(02_SRC:.c=.o) $(OGL_BIN)
     13 02_BIN = 02-cube
     14 
     15 03_SRC = 03-texture.c
     16 03_OBJ = $(03_SRC:.c=.o) $(OGL_BIN)
     17 03_BIN = 03-texture
     18 
     19 04_SRC = 04-lighting.c
     20 04_OBJ = $(04_SRC:.c=.o) $(OGL_BIN)
     21 04_BIN = 04-lighting
     22 
     23 05_SRC = 05-geometrytransforms.c
     24 05_OBJ = $(05_SRC:.c=.o) $(OGL_BIN)
     25 05_BIN = 05-geometrytransforms
     26 
     27 06_SRC = 06-performance.c
     28 06_OBJ = $(06_SRC:.c=.o) $(OGL_BIN)
     29 06_BIN = 06-performance
     30 
     31 
     32 
     33 CFLAGS ?= -std=c99 -Wall -fwrapv -g
     34 LIB_CFLAGS  += $(shell pkg-config --cflags glew gl glfw3)
     35 LIB_LDFLAGS += $(shell pkg-config --libs   glew gl glfw3) -lm
     36 
     37 .PHONY: all
     38 all: $(00_BIN) $(01_BIN) $(02_BIN) $(03_BIN) $(04_BIN) $(05_BIN) $(06_BIN)
     39 
     40 .PHONY: clean
     41 clean:
     42 	rm -rf \
     43 		$(00_OBJ) $(00_BIN) \
     44 		$(01_OBJ) $(01_BIN) \
     45 		$(02_OBJ) $(02_BIN) \
     46 		$(03_OBJ) $(03_BIN) \
     47 		$(04_OBJ) $(04_BIN) \
     48 		$(05_OBJ) $(05_BIN) \
     49 		$(06_OBJ) $(06_BIN)
     50 	$(MAKE) --directory=./ogl/ clean
     51 
     52 $(00_BIN): $(00_OBJ)
     53 
     54 $(01_BIN): $(01_OBJ)
     55 
     56 $(02_BIN): $(02_OBJ)
     57 
     58 $(03_BIN): $(03_OBJ)
     59 
     60 $(04_BIN): $(04_OBJ)
     61 
     62 $(05_BIN): $(05_OBJ)
     63 
     64 $(06_BIN): $(06_OBJ)
     65 
     66 .PHONY: $(OGL_BIN)
     67 $(OGL_BIN):
     68 	$(MAKE) --directory=./ogl/ all
     69 
     70 %.o: %.c
     71 	@echo [CC] $<
     72 	@$(CC) $(CFLAGS) $(LIB_CFLAGS) -c $< -o $@
     73 
     74 %: %.o
     75 	@echo [LD] $^ -o $@
     76 	@$(CC) $(LDFLAGS) $^ $(OGL_BIN) -o $@ $(LIB_LDFLAGS)
     77