156 lines
3.3 KiB
Makefile
156 lines
3.3 KiB
Makefile
# This file is generated with smake.sh.
|
|
# You can use this make file with instruction make to
|
|
# use one of build mode: debug, profile, develop, release.
|
|
# No need to call make clean if You make with other mode,
|
|
# because the Makefile containes rules for automatically clean.
|
|
# Some usage examples:
|
|
# CFLAGS="-march=core2 -mtune=core2" make
|
|
# LDFLAGS="-lexpat" make mode=profile
|
|
# Report bugs to <mecareful@gmail.com>
|
|
|
|
#_________________________________
|
|
# ENVIRONMENT |
|
|
#________________________________|
|
|
CC=cc
|
|
CXX=c++
|
|
LIBRARIES=
|
|
TARGET0=echo-client
|
|
TARGET1=echo-server
|
|
TARGET2=int2ip
|
|
TARGET3=ip2int
|
|
TARGET4=sock1
|
|
TARGET5=tmp1
|
|
TARGET= $(TARGET0) $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4) $(TARGET5)
|
|
INCLUDE1=-I$(HOME)/projects/include
|
|
INCLUDE2=-I/usr/include
|
|
INCLUDE=-I$(INCLUDE1) -I$(INCLUDE2)
|
|
|
|
#________________________________________
|
|
# BUILD SCRIPT (don't change) |
|
|
#_______________________________________|
|
|
ifeq ($(mode),)
|
|
mode = debug
|
|
endif
|
|
ifeq ($(mode),debug)
|
|
CFLAGS = -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion
|
|
LDFLAGS =
|
|
endif
|
|
ifeq ($(mode),profile)
|
|
CFLAGS = -O0 -g -p -ftest-coverage -Wcoverage-mismatch
|
|
LDFLAGS = -g -p
|
|
endif
|
|
ifeq ($(mode),develop)
|
|
CFLAGS += -O2 -g
|
|
LDFLAGS += -O1
|
|
endif
|
|
ifeq ($(mode),release)
|
|
CFLAGS += -O2
|
|
LDFLAGS += -O1
|
|
endif
|
|
|
|
CFLAGS += -Wall
|
|
LDFLAGS += -Wall $(LIBRARIES)
|
|
|
|
all: change_make_options $(TARGET)
|
|
|
|
ifneq ($(mode),debug)
|
|
ifneq ($(mode),profile)
|
|
ifneq ($(mode),develop)
|
|
ifneq ($(mode),release)
|
|
@echo "Invalid build mode."
|
|
@echo "Please use 'make mode=release', 'make mode=develop', 'make mode=profile' or 'make mode=debug'"
|
|
@exit 1
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
@echo ".........................."
|
|
@echo "Building on "$(mode)" mode "
|
|
@echo "CFLAGS=$(CFLAGS)"
|
|
@echo "LDFLAGS=$(LDFLAGS)"
|
|
@echo ".........................."
|
|
|
|
OLD_BUILD_MODE=$(shell grep ^MODE make_options.out 2>/dev/null | sed 's~^MODE=~~')
|
|
OLD_BUILD_CFLAGS=$(shell grep ^CFLAGS make_options.out 2>/dev/null | sed 's~^CFLAGS=~~')
|
|
OLD_BUILD_LDFLAGS=$(shell grep ^LDFLAGS make_options.out 2>/dev/null | sed 's~^LDFLAGS=~~')
|
|
change_make_options:
|
|
ifneq ($(mode)|$(CFLAGS)|$(LDFLAGS), $(OLD_BUILD_MODE)|$(OLD_BUILD_CFLAGS)|$(OLD_BUILD_LDFLAGS))
|
|
@echo CLEANING...
|
|
@make clean &>/dev/null
|
|
@echo MODE=$(mode) > make_options.out
|
|
@echo CFLAGS=$(CFLAGS) >> make_options.out
|
|
@echo LDFLAGS=$(LDFLAGS) >> make_options.out
|
|
endif
|
|
|
|
%.o :
|
|
$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
|
|
|
|
clean:
|
|
$(RM) *.o *.out callgrind.out.* *.gcno $(TARGET)
|
|
|
|
.PHONY: all change_make_options clean
|
|
|
|
#_________________________________
|
|
# R U L E S |
|
|
#________________________________|
|
|
target_objs0 = \
|
|
echo-client.o
|
|
|
|
$(TARGET0): $(target_objs0)
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs0)
|
|
|
|
|
|
target_objs1 = \
|
|
echo-server.o
|
|
|
|
$(TARGET1): $(target_objs1)
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs1)
|
|
|
|
|
|
target_objs2 = \
|
|
int2ip.o
|
|
|
|
$(TARGET2): $(target_objs2)
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs2)
|
|
|
|
|
|
target_objs3 = \
|
|
ip2int.o
|
|
|
|
$(TARGET3): $(target_objs3)
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs3)
|
|
|
|
|
|
target_objs4 = \
|
|
sock1.o
|
|
|
|
$(TARGET4): $(target_objs4)
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs4)
|
|
|
|
|
|
target_objs5 = \
|
|
tmp1.o
|
|
|
|
$(TARGET5): $(target_objs5)
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs5)
|
|
|
|
|
|
echo-client.o: \
|
|
echo-client.c
|
|
|
|
echo-server.o: \
|
|
echo-server.c
|
|
|
|
int2ip.o: \
|
|
int2ip.c
|
|
|
|
ip2int.o: \
|
|
ip2int.c
|
|
|
|
sock1.o: \
|
|
sock1.c
|
|
|
|
tmp1.o: \
|
|
tmp1.c
|
|
|