LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-22-2016, 11:56 PM   #1
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Rep: Reputation: 40
automake, Makefile.am how to make both 32 and 64 bit executable?


Hi group,
I would like to use automake to crate a Makefile that generates both 32 and 64 bit executable. My Makefile.am looks like this:
Code:
# src/event/Makefile.am
AM_CFLAGS     = --pedantic -Wall -std=c99 -O2
AM_LDFLAGS    =
bin_PROGRAMS  = event.x64
event_x64_SOURCES = event.c
AM_LDFLAGS    = -m32
bin_PROGRAMS  = event.x32
event_x32_SOURCES = event.c
But I get this error running make:
Code:
/usr/bin/ld: i386:x86-64 architecture of input file `event.o' is incompatible with i386 output
/usr/bin/ld: event.o: file class ELFCLASS64 incompatible with ELFCLASS32
/usr/bin/ld: final link failed: File in wrong format
collect2: error: ld returned 1 exit status
I am assuming I need a way to clean up before the second compile?

Any ideas?

Thanks for your time.
 
Old 12-23-2016, 01:24 AM   #2
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Perhaps a separate makefile for each?
 
Old 12-24-2016, 02:35 PM   #3
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by Brains View Post
Perhaps a separate makefile for each?
Yes, that will work but I would like to use just one source file since they be the same.
 
Old 12-24-2016, 04:54 PM   #4
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
I noticed an error in my Makefile.am:
Code:
AM_LDFLAGS should have been AM_CFLAGS
That does not resoluve my request.
 
Old 12-24-2016, 05:58 PM   #5
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Although I haven't tried it, can't see why it wouldn't work.

In short:
You may be able to add the "make install" command at the bottom of the first makefile followed by the "make clean" command, followed by a command executing the second makefile which can repeat "make install" and "make clean" after it's done.
 
Old 01-03-2017, 07:39 PM   #6
MrUmunhum
Member
 
Registered: May 2006
Location: Mt Umunhum, CA, USA, Earth
Distribution: Debian/ Fedora/ Ubuntu/ Raspbian
Posts: 549

Original Poster
Rep: Reputation: 40
All most there

I found the answer to my post which involves creating a sub-makefile.am for each compile:
Code:
 # src/event/Makefile.am
AM_LDLAGS  = --Pedantic -Wall -Std=C99 -O2
bin_PROGRAMS =
include x64.am
include arm.am
include i686.am
---------------------------------------
# src/event/x64.am
bin_PROGRAMS      += event_x64
event_x64_SOURCES  =  event.c
event_x64_CFLAGS   = -m64
---------------------------------------
# src/event/i686.am
bin_PROGRAMS       += event_i686
event_i686_SOURCES  =  event.c
event_i686_CFLAGS   = -m32
---------------------------------------
# src/event/arm.am
bin_PROGRAMS      += event_arm
event_arm_SOURCES  =  event.c
event_arm_CFLAGS   = -DARM
event_arm_CC       =  arm-linux-gnu-gcc
AM_CC              =  arm-linux-gnu-gcc
This solved my original question, so I marking this post solved. It does bring up a new question. Apparently Automake does not allow changing the compiler? The make runs but the output is not what I expected:
Code:
make[2]: Entering directory '/src/RHID/src/event'
gcc -DPACKAGE_NAME=\"event.c\ \" -DPACKAGE_TARNAME=\"event-c-\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"event.c\ \ 1.0\" -DPACKAGE_BUGREPORT=\"MrUmunhum@cruzio.com\ \" -DPACKAGE_URL=\"\" -DPACKAGE=\"event-c-\" -DVERSION=\"1.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LOCALTIME_R=1 -DHAVE_MEMSET=1 -DHAVE_SELECT=1 -DHAVE_STRERROR=1 -I.    -m64 -g -O2 -MT event_x64-event.o -MD -MP -MF .deps/event_x64-event.Tpo -c -o event_x64-event.o `test -f 'event.c' || echo './'`event.c
mv -f .deps/event_x64-event.Tpo .deps/event_x64-event.Po
gcc -m64 -g -O2   -o event_x64 event_x64-event.o  
gcc -DPACKAGE_NAME=\"event.c\ \" -DPACKAGE_TARNAME=\"event-c-\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"event.c\ \ 1.0\" -DPACKAGE_BUGREPORT=\"MrUmunhum@cruzio.com\ \" -DPACKAGE_URL=\"\" -DPACKAGE=\"event-c-\" -DVERSION=\"1.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LOCALTIME_R=1 -DHAVE_MEMSET=1 -DHAVE_SELECT=1 -DHAVE_STRERROR=1 -I.    -DARM -g -O2 -MT event_arm-event.o -MD -MP -MF .deps/event_arm-event.Tpo -c -o event_arm-event.o `test -f 'event.c' || echo './'`event.c
mv -f .deps/event_arm-event.Tpo .deps/event_arm-event.Po
gcc -DARM -g -O2   -o event_arm event_arm-event.o  
gcc -DPACKAGE_NAME=\"event.c\ \" -DPACKAGE_TARNAME=\"event-c-\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"event.c\ \ 1.0\" -DPACKAGE_BUGREPORT=\"MrUmunhum@cruzio.com\ \" -DPACKAGE_URL=\"\" -DPACKAGE=\"event-c-\" -DVERSION=\"1.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LOCALTIME_R=1 -DHAVE_MEMSET=1 -DHAVE_SELECT=1 -DHAVE_STRERROR=1 -I.    -m32 -g -O2 -MT event_i686-event.o -MD -MP -MF .deps/event_i686-event.Tpo -c -o event_i686-event.o `test -f 'event.c' || echo './'`event.c
mv -f .deps/event_i686-event.Tpo .deps/event_i686-event.Po
gcc -m32 -g -O2   -o event_i686 event_i686-event.o  
make[2]: Leaving directory '/src/RHID/src/event'
According to the man page gcc is suppose to support cross arm compiles with the -marm but it fails. And Automake is not overriding the CC option.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automake data dirs - what should go in Makefile.am? MadCactus Programming 4 02-20-2016 04:11 AM
automake, makefile.am, binary directory, both 32 bit and 64 bit executables? MrUmunhum Linux - Kernel 0 12-26-2011 04:47 PM
How can make Makefile detect 64 bit OS? yhus Programming 3 10-28-2008 06:05 PM
automake (Makefile.ac) & yacc phyx Linux - Software 0 03-02-2007 02:41 AM
automake, makefile, makefile.in and makefile.am Fond_of_Opensource Linux - Newbie 1 09-12-2006 08:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration