Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA-407107: makefile fixes to honour LDFLAGS #23

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ include/mtcerrno.h
scripts/generr
scripts/generr.o
scripts/ha_errnorc
stubs/cfread
*.o
*.a
62 changes: 18 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,37 @@
# Top-level Makefile
#
# This makefile installs the debug version (compiled without NDEBUG).
# To install release version, do "make release-install" or
# modify this makefile to do release install by default. See #here below.
#

.PHONY: build clean debug release
.PHONY: build clean debug

all: debug release
all: debug

debug:
@mkdir -p debug
@cd include; make DEFMAKE=default-debug.mk
@cd lib; make DEFMAKE=default-debug.mk
@cd daemon; make DEFMAKE=default-debug.mk
@cd commands; make DEFMAKE=default-debug.mk
@cd scripts; make DEFMAKE=default-debug.mk
$(MAKE) -C include DEFMAKE=default-debug.mk
$(MAKE) -C lib DEFMAKE=default-debug.mk
$(MAKE) -C daemon DEFMAKE=default-debug.mk
$(MAKE) -C commands DEFMAKE=default-debug.mk
$(MAKE) -C scripts DEFMAKE=default-debug.mk

release:
@mkdir -p release
@cd include; make DEFMAKE=default-release.mk
@cd lib; make DEFMAKE=default-release.mk
@cd daemon; make DEFMAKE=default-release.mk
@cd commands; make DEFMAKE=default-release.mk
@cd scripts; make DEFMAKE=default-release.mk

clean: debug-clean release-clean
clean: debug-clean

debug-clean:
@cd include; make clean DEFMAKE=default-debug.mk
@cd lib; make clean DEFMAKE=default-debug.mk
@cd daemon; make clean DEFMAKE=default-debug.mk
@cd commands; make clean DEFMAKE=default-debug.mk
@cd scripts; make clean DEFMAKE=default-debug.mk
@cd include; $(MAKE) clean DEFMAKE=default-debug.mk
@cd lib; $(MAKE) clean DEFMAKE=default-debug.mk
@cd daemon; $(MAKE) clean DEFMAKE=default-debug.mk
@cd commands; $(MAKE) clean DEFMAKE=default-debug.mk
@cd scripts; $(MAKE) clean DEFMAKE=default-debug.mk
-rmdir debug

release-clean:
@cd include; make clean DEFMAKE=default-release.mk
@cd lib; make clean DEFMAKE=default-release.mk
@cd daemon; make clean DEFMAKE=default-release.mk
@cd commands; make clean DEFMAKE=default-release.mk
@cd scripts; make clean DEFMAKE=default-release.mk
-rmdir release

#here
install: debug-install

debug-install:
@mkdir -p debug
@cd include; make install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
@cd lib; make install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
@cd daemon; make install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
@cd commands; make install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
@cd scripts; make install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk

release-install:
@mkdir -p release
@cd include; make install DESTDIR=$(DESTDIR) DEFMAKE=default-release.mk
@cd lib; make install DESTDIR=$(DESTDIR) DEFMAKE=default-release.mk
@cd daemon; make install DESTDIR=$(DESTDIR) DEFMAKE=default-release.mk
@cd commands; make install DESTDIR=$(DESTDIR) DEFMAKE=default-release.mk
@cd scripts; make install DESTDIR=$(DESTDIR) DEFMAKE=default-release.mk
@cd include; $(MAKE) install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
@cd lib; $(MAKE) install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
@cd daemon; $(MAKE) install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
@cd commands; $(MAKE) install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
@cd scripts; $(MAKE) install DESTDIR=$(DESTDIR) DEFMAKE=default-debug.mk
3 changes: 1 addition & 2 deletions daemon/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#
# daemon/Makefile
#

TARGET_DIR=daemon
DEFMAKE=default-debug.mk
include ../$(DEFMAKE)
Expand Down Expand Up @@ -33,7 +32,7 @@ OBJS +=$(OBJDIR)/hostweight.o
all: $(TARGET) $(LST)

$(TARGET): $(OBJS) $(HALIBS)
$(CC) -o $@ $(LIBS) $(OBJS) $(HALIBS) $(LIBS)
$(CC) -o $@ $(OBJS) $(HALIBS) $(LIBS)
@chmod 0755 $@

$(LST): $(TARGET)
Expand Down
11 changes: 3 additions & 8 deletions default-debug.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,19 @@

CC=gcc
SOURCEDIR=..
CFLAGS=-g -Wall -Wno-multichar -Werror=pointer-to-int-cast

override CFLAGS+=-g -Wall -Wno-multichar -Werror=pointer-to-int-cast -Og

OBJDIR=$(SOURCEDIR)/debug

INCDIR=$(SOURCEDIR)/include
INCLUDES=-I$(INCDIR)
LIBS=-lxml2 -lrt
LIBS=-lxml2 -lrt $(LDFLAGS)
HALIBS=$(OBJDIR)/libxha.a
INSDIR=/usr/libexec/xapi/cluster-stack/xhad
LOGCONFDIR=/etc/logrotate.d

.PHONY: build clean debug release
.PHONY: build clean debug

%.o: %.c $(INCDIR)/*.h
$(CC) $(CFLAGS) $(INCLUDES) -c $<

%.a: %.c $(INCDIR)/*.h
$(CC) $(CFLAGS) $(INCLUDES) -c $<
@$(AR) rv $@ $*.o
@$(RM) $*.o
27 changes: 0 additions & 27 deletions default-release.mk

This file was deleted.

1 change: 0 additions & 1 deletion include/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ all: $(TARGET)
mtcerrno.h: errdef.awk mtcerrno.def
gawk -f errdef.awk mtcerrno.def > $@

.PHONY: buildid.h
buildid.h:
sh buildid.sh > $@

Expand Down
7 changes: 5 additions & 2 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ OBJS +=config.o
OBJS +=error.o
OBJS +=weightio.o

TARGET=$(HALIBS)($(OBJS))
TARGET=$(HALIBS)

$(HALIBS): $(OBJS)
@$(AR) rv $@ $(OBJS)

all: $(TARGET)

install: $(TARGET)

clean:
rm -f $(HALIBS)
rm -f $(HALIBS) $(OBJS)
2 changes: 0 additions & 2 deletions readme
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ Date: April 18, 2008
Top-level makefile of xha.
default-debug.mk
Various make defaults for debug build.
default-release.mk
Various make defaults for release build.
commands/
Source files of utility programs for the HA scripts.
daemon/
Expand Down
4 changes: 2 additions & 2 deletions stubs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ TARGET= $(SCRIPTDIR)/cfread \
$(FRC)

all:
(cd cfread-libxml2; make)
$(MAKE) -C cfread-libxml2

install:
-mkdir -p $(DESTDIR)$(SCRIPTDIR)
-cp ha_* cfread $(DESTDIR)$(SCRIPTDIR)

clean:
(cd cfread-libxml2; make clean)
$(MAKE) -C cfread-libxml2 clean
-rm -f $(TARGET)
Loading