Error: suffix or operands invalid for `push' - compilation

I'm trying to compile someone else's Fortran code and getting strange compiler errors. In particular, I get errors like this:
pgf77 -c -pc 64 -g77libs hpair.f
/tmp/dstolars/pgf77kdVzoC: Assembler messages:
/tmp/dstolars/pgf77kdVzoC:12: Error: suffix or operands invalid for `push'
/tmp/dstolars/pgf77kdVzoC:7559: Error: suffix or operands invalid for `push'
/tmp/dstolars/pgf77kdVzoC:7818: Error: suffix or operands invalid for `push'
There were not any files in /tmp/dstolars/pgf77kdVzoC.
Here is my makefile
OBJS = hpair.o Cteq61Pdf.o mrst2001.o
LIBS = $(CERN)/libpdflib804.a $(CERN)/libpawlib.a $(CERN)/libgrafX11.a $(CERN)/libpacklib.a $(CERN)/libmathlib.a $(CERN)/libkernlib.a
FFLAGS= -pc 64 -g77libs
FC=pgf77
# Commands:
.f.o:
$(FC) -c $(FFLAGS) $*.f
hpair: $(OBJS)
$(FC) $(FFLAGS) $(OBJS) $(LIBS) -o run
clean:
rm -f $(OBJS)
When I do make --just-print I get
pgf77 -c -pc 64 -g77libs hpair.f
pgf77 -c -pc 64 -g77libs Cteq61Pdf.f
pgf77 -c -pc 64 -g77libs mrst2001.f
pgf77 -pc 64 -g77libs hpair.o Cteq61Pdf.o mrst2001.o /afs/cern.ch/sw/lcg/hepsoft/0.9/x86_64-slc6-gcc47-opt/share/cernlib/libpdflib804.a /afs/cern.ch/sw/lcg/hepsoft/0.9/x86_64-slc6-gcc47-opt/share/cernlib/libpawlib.a /afs/cern.ch/sw/lcg/hepsoft/0.9/x86_64-slc6-gcc47-opt/share/cernlib/libgrafX11.a /afs/cern.ch/sw/lcg/hepsoft/0.9/x86_64-slc6-gcc47-opt/share/cernlib/libpacklib.a /afs/cern.ch/sw/lcg/hepsoft/0.9/x86_64-slc6-gcc47-opt/share/cernlib/libmathlib.a /afs/cern.ch/sw/lcg/hepsoft/0.9/x86_64-slc6-gcc47-opt/share/cernlib/libkernlib.a -o run

Related

How to compile avr c and c++ source code with make

I was trying to compile some code written in c and c++ for an atmega32u4.
I wrote a makefile from information gathered from the internet, but it fails for some reason.
If I run the commands separately from the command line, they all work. However running the make command gives the following error:
main.cpp:3:10: fatal error: avr/io.h: No such file or directory
The contents of the main.cpp file are not really relevant, it's just a blink code.
The makefile looks like this:
all: init clean $(patsubst %.cpp, %.hex, $(wildcard *.cpp))
avr-size -A $(BUILDPATH)/*.elf
%.c.o: %.c
#mkdir -p $(BUILDPATH)
avr-gcc -c -g -Os -w -mmcu=$(CHIP) $^ -o $(BUILDPATH)/$#
%.cpp.o: %.cpp
#mkdir -p $(BUILDPATH)
avr-g++ -c -g -Os -w -mmcu=$(CHIP) $^ -o $(BUILDPATH)/$#
%.elf: %.o
avr-gcc -g -Os -w -mmcu=$(CHIP) $(BUILDPATH)/$^ -o $(BUILDPATH)/$#
%.hex: %.elf
avr-objcopy -R .eeprom --change-section-lma .eeprom=0 -O ihex $(BUILDPATH)/$^ $(BUILDPATH)/$#
So what am I doing wrong? Do I have to set up some environment variables or is the structure of the makefile incorrect?

I don't have this line: "cc drone.c hex1 clean -o drone"

I make a simple makefile for compile the code for a project. when I use the command:
$ make drone
The output files are correct, but the make utility gives me a result that I don't understand (from line 10 to line 14):
1: avr-gcc -g -Os -mmcu=atmega328p -DF_CPU=16000000UL -c drone.c
2: drone.c:1:0: warning: "F_CPU" redefined
3: #define F_CPU 16000000
4: ^
5: <command-line>:0:0: note: this is the location of the previous definition
6: avr-gcc -g -Os -mmcu=atmega328p -DF_CPU=16000000UL -c ./lib/lib_uart.c
7: avr-gcc -g -mmcu=atmega328p -o drone.elf drone.o lib_uart.o
8: avr-objcopy -j .text -j .data -O ihex drone.elf drone.hex
9: rm *.o *.elf
10: cc drone.c hex1 clean -o drone
11: cc: error: hex1: No such file or directory
12: cc: error: clean: No such file or directory
13: <builtin>: recipe for target 'drone' failed
14: make: *** [drone] Error 1
The makefile text is:
CPU=atmega328p
CLK=16000000UL
PRG=avrisp
BRATE=-b 19200
PORT=ttyACM0
libs_comando=lib_uart.o
libs_drone=lib_uart.o
drone: hex1 clean
comando: hex2 clean
# drone
hex1: elf1
avr-objcopy -j .text -j .data -O ihex drone.elf drone.hex
elf1: obj1 $(libs_drone)
avr-gcc -g -mmcu=$(CPU) -o drone.elf drone.o $(libs_drone)
obj1:
avr-gcc -g -Os -mmcu=$(CPU) -DF_CPU=$(CLK) -c drone.c
#--------------------------------------------------------------------------------
# comando
hex2: elf2
avr-objcopy -j .text -j .data -O ihex comando.elf comando.hex
elf2: obj2 $(libs_comando)
avr-gcc -g -mmcu=$(CPU) -o comando.elf comando.o $(libs_comando)
obj2:
avr-gcc -g -Os -mmcu=$(CPU) -DF_CPU=$(CLK) -c comando.c
#--------------------------------------------------------------------------------
# library
lib_uart.o:
avr-gcc -g -Os -mmcu=$(CPU) -DF_CPU=$(CLK) -c ./lib/lib_uart.c
#--------------------------------------------------------------------------------
clean:
rm *.o *.elf
flash_drone: drone.hex
avrdude -c $(PRG) -p $(CPU) $(BRATE) -P /dev/$(PORT) -U flash:w:drone.hex:i
flash_comando: comando.hex
avrdude -c $(PRG) -p $(CPU) $(BRATE) -P /dev/$(PORT) -U flash:w:comando.hex:i
The problem is drone: hex1 clean rule. Since you've got drone.c file in your current directory, implicit rule %: %.c is matched. The easiest ways to fix this are to disble implicit rules, or rename drone to something else, or move drone.c file in another directory (say src).
A better solution is not to fight implicit rules but to build on them. Here's a snippet.
# Programs
CC := avr-gcc
OBJCOPY := avr-objcopy
# Flags
CFLAGS := -g -Os
TARGET_ARCH := -mmcu=atmega328p -DF_CPU=16000000UL
OBJFLAGS := -j .text -j .data -O ihex
# Libraray file location
vpath lib_%.c lib
all: drone.hex
drone: lib_uart.o
%.hex: %
$(OBJCOPY) $(OBJFLAGS) $< $#
Will produce:
avr-gcc -g -Os -mmcu=atmega328p -DF_CPU=16000000UL -c -o lib_uart.o lib/lib_uart.c
avr-gcc -g -Os -mmcu=atmega328p -DF_CPU=16000000UL drone.c lib_uart.o -o drone
avr-objcopy -j .text -j .data -O ihex drone drone.hex

makefile for ARM: cannot specify -o with -c or -S and mult compilations

I'm modifying this makefile to use with another project and I get a gcc error saying I cannot specify -o with -c.
The line near the bottom that says:
.c.o:
$(CC) $(CC_FLAGS) ... -o $# &<
has the -o
but CC_FLAGS = $(MCU_CC_FLAGS) -c ...
I don't see how this makefile worked in the first place.

errors while runing makefile with cygwin

i have ran this makefile in cygwin and i got some errors this is makefile:
FFLAGS=
BFLAGS=-d -v -y
CFLAGS=-g -Wall -Wextra -std=c++11 -Wno-write-strings -I /usr/local/boost_1_50_0
FLEX=flex
BISON=bison
CC=g++
SRCS=y.tab.c ast.cpp tokentable.cpp symboltable.cpp main.cpp lex.yy.c semanticanalyzer.cpp astnodevisitor.cpp constants.cpp astnodetypechecker.cpp utility.cpp astnodecodegenerator.cpp
OBJS=y.tab.o ast.o tokentable.o symboltable.o main.o lex.yy.o semanticanalyzer.o astnodevisitor.o constants.o astnodetypechecker.o utility.o astnodecodegenerator.o
cooc : ${OBJS}
${CC} ${CFLAGS} -o $# ${OBJS}
%.o : %.cpp
${CC} ${CFLAGS} -c $<
y.tab.c : cool.y
${BISON} ${BFLAGS} cool.y
lex.yy.c : cool.flex
${FLEX} ${FFLAGS} cool.flex
.depend: ${SRCS}
rm -f ./.depend
${CC} ${CFLAGS} -MM $^>>./.depend
include .depend
and i got this errors:
MAKE Version 5.0 Copyright (c) 1987, 1997 Borland International
Error makefile 25: Colon expected
Error makefile 26: Command syntax error
Error makefile 27: Command syntax error
Error makefile 29: Command syntax error
* 4 errors during make *
This is a GNU make makefile. You are running Windows nmake. Those two programs are not compatible. If you're using cygwin, install the GNU make program for cygwin and use that instead.

Problems wih make file code

When i run the code below , it give me an error message which is :
cc1: warning: main.c: not a directory [enabled by default]
frequent.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: * [main] Error 1
CC = gcc
CPPFLAGS = -I
main: main.c headers.h sortt.o frequent.o
#$(CC) $(CPPFLAGS) -c $^ -o $#
sortt.o: headers.h sortt.c
$(CC) $(CPPFLAGS) -c $< -o $#
frequent.o: headers.h frequent_word.c search_similar_word.o
$(CC) $(CPPFLAGS) -c $< -o $#
You have a lot of errors in your rules. Why is frequent.o listing search_similar_word.o as a prerequisite? There's no reason that you can't build frequent.o before or at the same time as search_similar_word.o.
Also, you are using $< in the compilation line which expands to the first prerequisite, but the first prerequisite for frequent.o is headers.h, so you're trying to compile headers.h which is wrong: you want to compile frequent_word.c.
Ditto for sortt.o.
It's also very odd to name your object files with different names than the source files.
In your CPPFLAGS you're listing a -I flag but you've given it no argument: that flag takes a directory as an argument.
And finally, you are using the -c flag when you're trying to link the final object (I'm assuming the comment character # is just an artifact of debugging); that's not right as the -c flag tells the compiler to generate an object file, and to not link the final object.
Your makefile should look something like this:
CC = gcc
CPPFLAGS = -I .
main: main.c headers.h sortt.o frequent.o
$(CC) $(CPPFLAGS) $^ -o $#
sortt.o: sortt.c headers.h
$(CC) $(CPPFLAGS) -c $< -o $#
frequent.o: frequent_word.c headers.h
$(CC) $(CPPFLAGS) -c $< -o $#
I have no idea what to do with search_similar_word.o since it doesn't seem to be used anywhere in your build.

Resources