...
 
Commits (1)
  • Sebastien Badia's avatar
    friendly-makefile · 408de3b4
    Sebastien Badia authored
    Description : Fix upstream Makefile
     The upstream Makefile is OpenSUSE-specific, let debianize it and activate
     hardening flags.
    Author: Tomasz Buchert <tomasz@debian.org>
    Forwarded: not-needed
    Last-Update: 2014-01-05
    Reviewed-By: Sebastien Badia's avatarSebastien Badia <seb@sebian.fr>
    408de3b4
DPKG_EXPORT_BUILDFLAGS=1
include /usr/share/dpkg/buildflags.mk
RUN_VERSION := $(shell if [ ! -f VERSION ]; then ./git2log --update --version VERSION; fi)
RUN_CHANGELOG := $(shell if [ ! -f CHANGELOG ]; then ./git2log --update --changelog CHANGELOG; fi)
ARCH := $(shell uname -m)
ifneq ($(filter i386 i486 i586 i686, $(ARCH)),)
ARCH := i386
endif
GIT2LOG := $(shell if [ -x ./git2log ] ; then echo ./git2log --update ; else echo true ; fi)
GITDEPS := $(shell [ -d .git ] && echo .git/HEAD .git/refs/heads .git/refs/tags)
CC ?= gcc
CFLAGS += -g -O2 -fPIC -fomit-frame-pointer -Wall
CC = gcc
CFLAGS = -g -O2 -fPIC -fomit-frame-pointer -Wall
ifneq ($(filter x86_64, $(ARCH)),)
LIBDIR = /usr/lib64
else
LIBDIR = /usr/lib
ifndef LIBDIR
ifneq ($(filter x86_64, $(ARCH)),)
LIBDIR = /usr/lib64
else
LIBDIR = /usr/lib
endif
endif
LIBX86 = libx86emu
VERSION := $(shell $(GIT2LOG) --version VERSION ; cat VERSION)
MAJOR_VERSION := $(shell $(GIT2LOG) --version VERSION ; cut -d . -f 1 VERSION)
LIBX86 := libx86emu
VERSION := $(shell cat VERSION)
MAJOR_VERSION := $(shell cut -d . -f 1 VERSION)
CFILES = $(wildcard *.c)
OBJS = $(CFILES:.c=.o)
......@@ -24,15 +30,12 @@ OBJS = $(CFILES:.c=.o)
LIB_NAME = $(LIBX86).so.$(VERSION)
LIB_SONAME = $(LIBX86).so.$(MAJOR_VERSION)
.PHONY: all shared install test clean
.PHONY: all shared install test clean release empty
%.o: %.c
$(CC) -c $(CFLAGS) $<
all: changelog shared
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $<
changelog: $(GITDEPS)
$(GIT2LOG) --changelog changelog
all: shared
shared: $(LIB_NAME)
......@@ -43,7 +46,7 @@ install: shared
install -m 644 -D include/x86emu.h $(DESTDIR)/usr/include/x86emu.h
$(LIB_NAME): .depend $(OBJS)
$(CC) -shared -Wl,-soname,$(LIB_SONAME) $(OBJS) -o $(LIB_NAME)
$(CC) $(CFLAGS) $(CPPLAGS) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) $(OBJS) -o $(LIB_NAME)
test:
make -C test
......@@ -52,9 +55,16 @@ clean:
make -C test clean
rm -f *.o *~ include/*~ *.so.* .depend
release:
rm -f VERSION CHANGELOG
@make empty
empty:
@echo "VERSION and CHANGELOG generated."
ifneq "$(MAKECMDGOALS)" "clean"
.depend: $(CFILES)
@$(CC) -MG -MM $(CFLAGS) $(CFILES) >$@
@$(CC) -MG -MM $(CFLAGS) $(CPPLAGS) $(LDFLAGS) $(CFILES) >$@
-include .depend
endif