Changed Makefile to work with gcc instead of g++
[allwinner_tvout_manipulator.git] / src / Makefile
1 ############################################################################
2 # Workfile: Makefile
3 # Author: Daniel Giritzer, S1510306010
4 #         giri@nwrk.biz
5 # Date: 06.04.2016
6 # Description:  Universal Makefile for Unix based Operating Systems
7 #
8 # Remarks:      Compatible with CodeBlocks (C::B)
9 #                       PROJNAME variable should match your project name!
10 # Revision: 5.4
11 # Usage: make debug             - builds debug version
12 #                make release   - builds release version
13 #                make all       - builds debug and release version
14 #                make clean     - cleans project
15 #                make rebuild   - builds everything from scratch
16 ############################################################################
17
18 ####################
19 #GENERAL | EDIT 1/3
20 ####################
21 WORKDIR = $(shell pwd)
22 SOURCES := $(shell ls *.c)
23 PROJNAME = tvout
24
25 CC = gcc
26 CXX = g++
27 AR = ar
28 LD = g++
29 WINDRES = windres
30
31 INC =
32 CFLAGS = -Wall -fexceptions
33 RESINC =
34 LIBDIR =
35 LIB =
36 LDFLAGS =
37
38 ############################
39 #DEBUG SETTINGS | EDIT: 2/3
40 ############################
41 INC_DEBUG = $(INC)
42 CFLAGS_DEBUG = $(CFLAGS) -g
43 RESINC_DEBUG = $(RESINC)
44 RCFLAGS_DEBUG = $(RCFLAGS)
45 LIBDIR_DEBUG = $(LIBDIR)
46 LIB_DEBUG = $(LIB)
47 LDFLAGS_DEBUG = $(LDFLAGS)
48 OBJDIR_DEBUG = obj/Debug
49 DEP_DEBUG =
50 OUT_DEBUG = bin/Debug/$(PROJNAME)
51
52
53 ##############################
54 #RELEASE SETTINGS | EDIT: 3/3
55 ##############################
56 INC_RELEASE = $(INC)
57 CFLAGS_RELEASE = $(CFLAGS) -O2
58 RESINC_RELEASE = $(RESINC)
59 RCFLAGS_RELEASE = $(RCFLAGS)
60 LIBDIR_RELEASE = $(LIBDIR)
61 LIB_RELEASE = $(LIB)
62 LDFLAGS_RELEASE = $(LDFLAGS) -s
63 OBJDIR_RELEASE = obj/Release
64 DEP_RELEASE =
65 OUT_RELEASE = bin/Release/$(PROJNAME)
66
67 ############################
68 #OBJECT LISTS | DO NOT EDIT!
69 ############################
70 OBJ_DEBUG = $(addprefix $(OBJDIR_DEBUG)/,$(SOURCES:%.c=%.o))
71 OBJ_RELEASE = $(addprefix $(OBJDIR_RELEASE)/,$(SOURCES:%.c=%.o))
72
73
74 ##########################
75 #FUNCTIONS | DO NOT EDIT!
76 ##########################
77
78 ######## General
79 all All: debug release
80 clean Clean: cleanDebug cleanRelease
81 rebuild Rebuild: clean debug release
82
83 ######## DEBUG
84 before_debug:
85         test -d bin/Debug || mkdir -p bin/Debug
86         test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
87
88 after_debug:
89
90 debug Debug: before_debug out_debug after_debug
91
92 out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
93         $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG)
94
95 $(OBJDIR_DEBUG)/%.o: %.c
96         $(CC) $(CFLAGS_DEBUG) $(INC_DEBUG) -c $< -D_DEBUG -o $@
97
98 clean_debug cleanDebug:
99         rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
100         rm -rf bin/Debug
101         rm -rf $(OBJDIR_DEBUG)
102
103
104 ######## RELEASE
105 before_release:
106         test -d bin/Release || mkdir -p bin/Release
107         test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
108
109 after_release:
110
111 release Release: before_release out_release after_release
112
113 out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
114         $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
115
116 $(OBJDIR_RELEASE)/%.o: %.c
117         $(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c $< -o $@
118
119 clean_release cleanRelease:
120         rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
121         rm -rf bin/Release
122         rm -rf $(OBJDIR_RELEASE)
123
124 .PHONY: before_debug after_debug clean_debug cleanDebug before_release after_release clean_release cleanRelease
125