[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: packagers note: do not run ld directly



Hi,

> e.g. a makefile line:
> 
> 	$(LD) -shared -o $@ $(objs)
> 
> should be:	
> 
> 	$(CC) -shared -o $@ $(objs)
> 
> Best practice is to use consistently the flags otherwise passed to
> the compiler, and also use LDFLAGS, i.e.:
> 
> 	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(objs)

Are you sure CFLAGS should be used?

The default GNU make rules don't do so:

LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH)
%: %.o
        $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@


Just for inspiration, I use the following rules in my Makefiles:

%.so.$(SOMAJOR).$(SOMINOR): CFLAGS += -fPIC
%.so.$(SOMAJOR).$(SOMINOR): LDFLAGS += -shared \
        -Wl,-soname,$(patsubst %.so.$(SOMAJOR).$(SOMINOR),%.so.$(SOMAJOR),$@)
%.so.$(SOMAJOR).$(SOMINOR): %.o
        $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@

Regards,
-- 
TJ. (Brno, CZ), BaseOS, Red Hat


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]