Restructure Makefiles

Use common.mk for basic toolchain settings and installation variables.
This commit is contained in:
hasufell 2014-05-10 23:51:45 +02:00
parent 8dd46fc2f6
commit e1d18aad12
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
4 changed files with 28 additions and 48 deletions

View File

@ -1,3 +1,5 @@
include common.mk
all:
$(MAKE) -C src all

24
common.mk Normal file
View File

@ -0,0 +1,24 @@
# compiler, tools
CC = clang
PKG_CONFIG ?= pkg-config
# flags
CFLAGS ?= -march=native -O2 -pipe
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function
ifeq ($(shell $(CC) -v 2>&1 | grep 'gcc version' &>/dev/null && echo 1),1)
CFLAGS += -Wno-unused-but-set-variable
endif
LDFLAGS ?= -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu
ifndef NODEBUG
CFLAGS += -O0 -g3
endif
# install variables
INSTALL = install
INSTALL_BIN = install -m755
INSTALL_DIR = install -d
PREFIX = /usr/local
LIBDIR = lib64
INSTALL_BINDIR = $(PREFIX)/bin
INSTALL_LIBDIR = $(PREFIX)/$(LIBDIR)

View File

@ -1,18 +1,4 @@
# compiler, tools
CC = clang
PKG_CONFIG ?= pkg-config
# flags
CFLAGS ?= -march=native -O2 -pipe
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function
ifeq ($(shell $(CC) -v 2>&1 | grep 'gcc version' &>/dev/null && echo 1),1)
CFLAGS += -Wno-unused-but-set-variable
endif
LDFLAGS ?= -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu
ifndef NODEBUG
CFLAGS += -O0 -g3
endif
include ../common.mk
TARGET = drow-engine
HEADERS = err.h common.h print.h filereader.h gl_draw.h vector.h half_edge.h
@ -23,15 +9,6 @@ CFLAGS += $(shell $(PKG_CONFIG) --cflags gl glu glib-2.0)
LIBS = $(shell $(PKG_CONFIG) --libs gl glu glib-2.0) -lglut -lm
CPPFLAGS += -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_GNU_SOURCE
# install variables
INSTALL = install
INSTALL_BIN = install -m755
INSTALL_DIR = install -d
PREFIX = /usr/local
LIBDIR = lib64
INSTALL_BINDIR = $(PREFIX)/bin
INSTALL_LIBDIR = $(PREFIX)/$(LIBDIR)
%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(INCS) -c $*.c

View File

@ -1,18 +1,4 @@
# compiler, tools
CC = clang
PKG_CONFIG ?= pkg-config
# flags
CFLAGS ?= -march=native -O2 -pipe
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function
ifeq ($(shell $(CC) -v 2>&1 | grep 'gcc version' &>/dev/null && echo 1),1)
CFLAGS += -Wno-unused-but-set-variable
endif
LDFLAGS ?= -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu
ifndef NODEBUG
CFLAGS += -O0 -g3
endif
include ../../common.mk
TARGET = test
HEADERS = cunit.h
@ -23,15 +9,6 @@ CFLAGS += $(shell $(PKG_CONFIG) --cflags gl glu glib-2.0)
LIBS = $(shell $(PKG_CONFIG) --libs gl glu glib-2.0) -lglut -lm -lcunit
CPPFLAGS += -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_GNU_SOURCE
# install variables
INSTALL = install
INSTALL_BIN = install -m755
INSTALL_DIR = install -d
PREFIX = /usr/local
LIBDIR = lib64
INSTALL_BINDIR = $(PREFIX)/bin
INSTALL_LIBDIR = $(PREFIX)/$(LIBDIR)
%.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(INCS) -c $*.c